import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 点检记录信息 */
export interface EquipmentCheckRecord {
  id: number // id
  equipmentId?: number // 设备id
  checkUser: number // 点检人
  checkTime: string | Dayjs // 点检时间
  checkResult: number // 点检结果 1通过 2不通过
  checkItemId: string // 点检通过项ID
}

// 点检记录 API
export const EquipmentCheckRecordApi = {
  // 查询点检记录分页
  getEquipmentCheckRecordPage: async (params: any) => {
    return await request.get({ url: `/business/equipment-check-record/page`, params })
  },

  // 查询点检记录详情
  getEquipmentCheckRecord: async (id: number) => {
    return await request.get({ url: `/business/equipment-check-record/get?id=` + id })
  },

  // 新增点检记录
  createEquipmentCheckRecord: async (data) => {
    return await request.post({ url: `/business/equipment-check-record/create`, data })
  },

  // 修改点检记录
  updateEquipmentCheckRecord: async (data: EquipmentCheckRecord) => {
    return await request.put({ url: `/business/equipment-check-record/update`, data })
  },

  // 删除点检记录
  deleteEquipmentCheckRecord: async (id: number) => {
    return await request.delete({ url: `/business/equipment-check-record/delete?id=` + id })
  },

  /** 批量删除点检记录 */
  deleteEquipmentCheckRecordList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-check-record/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出点检记录 Excel
  exportEquipmentCheckRecord: async (params) => {
    return await request.download({ url: `/business/equipment-check-record/export-excel`, params })
  }
}
